package com.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Timer;

public abstract class Skill implements CommandTimerTask, Serializable{
	private static final long serialVersionUID = 1790601405799169306L;
	
	protected transient Timer timer;
	protected transient ConcCommandTimerTask timerTask;
	protected int timerPeriod = -1;
	protected ArrayList<Block> blocks;
	protected int skillType;
	protected Block currentBlock;
	protected int skillDuringTime;
	
	public Skill(){
		blocks = new ArrayList<Block>();
	}
	
	public void endSkill(Character par){
		par.setAngryGauge(0);
	}
	
	public void addBlock(Block bk){
		if(!blocks.contains(bk))
			blocks.add(bk);
	}
	
	public void timerTask(){
		
	}
	
	protected void startTimer(){
		timer = new Timer();
		timerTask = new ConcCommandTimerTask(this);
		timer.schedule(timerTask,0,timerPeriod);
	}
	
	protected void endTimer(){
		timer.cancel();
		timer = null;
		timerTask = null;
	}
	
	public ArrayList<Block> getBlocksList(){
		return blocks;
	}
	
	public int getSkillType(){	return this.skillType; }
	
	public Block getCurrentBlock(){  
		Block temp = currentBlock; 
		currentBlock = null;
		return temp; 
	}
	
	public int getSkillDuringTime(){
		return this.skillDuringTime;
	}
	
	private boolean isTimer(){
		if(timerPeriod == -1)
			return false;
		else
			return true;
	}
	
	public void timerToggle(){
		if(isTimer()){
		if(timer == null)
			startTimer();
		else
			endTimer();
		}	
	}
	
	public abstract void startSkill(Character par);
	public abstract void performSkill(Character par,Block block);
}
